import type { TrainingResp, UserTrainingResp,SaveAnswerReport, RestartContainer } from '@/types/training';
import { defHttp } from '@/utils/request/index';

enum Api {
    TrainingList = '/training',
    StartTraining = 'user_training/start',
    SaveAnswerReport = "/user_training/save_answer_report",
    RestartContainer = "/user_training/restart_container",
    ResetContainer = "/user_training/reset_container"
}

/**
 * 查询实训列表
 */
export const trainingListApi = (name?: string) => defHttp.get<TrainingResp[]>(Api.TrainingList, { name: name  })

/**
 * 开启实训
 */
export const startTrainingApi = (trainingId:number) => defHttp.get<UserTrainingResp>(Api.StartTraining,{trainingId})

/**
 * 提交答题报告
 */
export const saveAnswerReportApi = (params:SaveAnswerReport) => defHttp.post(Api.SaveAnswerReport,params)

/**
 * 重启容器
 */
export const restartContainerApi = (params: RestartContainer) => defHttp.post(Api.RestartContainer,params)

/**
 * 重启容器
 */
export const resetContainerApi = (params: RestartContainer) => defHttp.post(Api.ResetContainer,params)
